var username1 = getCookie("username_modify");
$("#username").html("&nbsp;&nbsp;" + username1);
$("#modify_btn").click(function() {
	if (checkPwds()) {
		var password = $("#newPwd1").val();
		$.ajax({
			url : "http://localhost:8080/ciic-vote/user/modifyPwd.do",
			type : "post",
			data : {
				"username" : username1,
				"password" : password
			},
			dataType : "json",
			success : function(result) {
				if (result.status == 0) {
					alert("修改成功");
				}
			}
		});
	}
});
function checkPwds() {
	var newPwd1 = $("#newPwd1").val().trim();
	var newPwd2 = $("#newPwd2").val().trim();
	if (null == newPwd1 || "" == newPwd1) {
		$(".newPwd1msg").text("新密码不能为空");
		return false;
	} else if (null == newPwd2 || "" == newPwd2) {
		$(".newPwd2msg").html("确认密码不能为空");
		return false;
	} else if (newPwd1 != newPwd2) {
		$(".newPwd2msg").html("确认密码与新密码不一致");
		return false;
	} else {
		return true;
	}
}